// 人脸识别功能

// 人脸识别
$('#compareFaceBtn').click(function() {
    const originalText = showLoading('compareFaceBtn');
    var formData = new FormData($('#compareFacesForm')[0]);
    
    $.ajax({
        url: '/compare_faces',
        type: 'POST',
        data: formData,
        processData: false,
        contentType: false,
        success: function(response) {
            const confidence = (response.confidence * 100).toFixed(2);
            const message = `识别结果: <strong>${response.matched_name}</strong><br>置信度: <strong>${confidence}%</strong>`;
            showResult('compareResult', message, true);
            resetUploadArea('recognitionUploadArea');
        },
        error: function(xhr) {
            showResult('compareResult', '识别失败: ' + xhr.responseText, false);
        },
        complete: function() {
            restoreButton('compareFaceBtn', originalText);
        }
    });
}); 